package com.winz.cultureapp.activity;

import android.content.Intent;
import android.graphics.Color;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TextView;

import com.winz.cultureapp.R;
import com.winz.cultureapp.base.BaseAppCompatActivity;
import com.winz.cultureapp.constants.Constants;
import com.winz.cultureapp.utils.SharePrefsUtil;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 志愿活动 -- 详情
 */
public class VolunteerDesActivity extends BaseAppCompatActivity {
    @BindView(R.id.tv_title)
    TextView mTv_title;
    @BindView(R.id.tv_date)
    TextView mTv_tv_date;
    @BindView(R.id.wv_volunteer_des)
    WebView mWv_des;
    @BindView(R.id.tv_location)
    TextView mTv_location;
    @BindView(R.id.tv_time)
    TextView mTv_time;
    @BindView(R.id.tv_state)
    TextView mTv_state;
    @BindView(R.id.tv_tip)
    TextView mTv_tip;
    @BindView(R.id.tv_zbdw)
    TextView mTv_zbdw;
    @BindView(R.id.tv_cbdw)
    TextView mTv_cbdw;
    private String id;


    @Override
    protected int contentView() {

        return R.layout.activity_volunteer_des;
    }

    @Override

    protected void initViews() {
        String data = "https://mini.eastday.com/a/n190113154519154.html?qid=02012";

        mWv_des.getSettings().setJavaScriptEnabled(true);//设置WebView支持JS
        mWv_des.getSettings().setDefaultTextEncodingName("utf-8");//设置解码时的字符集
        mWv_des.getSettings().setLoadWithOverviewMode(true);
        mWv_des.getSettings().setUseWideViewPort(true);
        mWv_des.getSettings().setSupportZoom(true);
        mWv_des.getSettings().setBuiltInZoomControls(true);
        mWv_des.getSettings().setDomStorageEnabled(true);
        mWv_des.getSettings().setBuiltInZoomControls(false);
        mWv_des.setWebViewClient(new WebViewClient() {
            /*
            此处能拦截超链接的url,即拦截href请求的内容.
            */
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                mWv_des.loadUrl(url);

                return true;
            }

        });
        mWv_des.loadUrl(data);


    }


    @Override
    protected void initEvents() {

    }

    @Override
    protected void loadDatas(Intent intent) {
        if (intent != null){
            if (intent.getExtras() != null){
                id = intent.getExtras().getString(Constants.KEY.VOLUNTEER.ITEM_ID);
            }
        }
    }

    @OnClick({R.id.iv_back, R.id.iv_share, R.id.ll_location, R.id.ll_comment, R.id.ll_collection, R.id.tv_join})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.iv_share:
                showMsg("开发中");
                break;
            case R.id.ll_location:
                showMsg("开发中");
                break;
            case R.id.ll_comment:
                showMsg("开发中");
                break;
            case R.id.ll_collection:
                showMsg("开发中");
                break;
            case R.id.tv_join: // 报名
                // 判断是否是志愿者
                if (true){
                    startActivity(RegisterVolunteerActivity.class,false);
                }
                break;
        }
    }
}
